{include file="public/header"/}
<body>
	<div class="x-nav" style="margin-top: 10px;">
		<span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">文章管理</a>
        <a>
          <cite>文章分类</cite></a>
      </span>
		<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
			<i class="layui-icon" style="line-height:30px">ဂ</i></a>
	</div>
	<div class="x-body">
		<xblock>
			<!--<button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button>-->
			<button class="layui-btn" onclick="x_admin_show('添加分类','{:url("newsClass/add_class")}','600px' ,'300px')"><i class="layui-icon"></i>添加分类</button>
			<span class="x-right" style="line-height:40px">共有数据：{$total} 条</span>
		</xblock>
		<table class="layui-table">
			<thead>
				<tr>
					<!--<th>
						<div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
					</th>-->
					<th class="text-center">ID</th>
					<th class="text-center">分类名称</th>
					<th class="text-center">排序</th>
					<th class="text-center">操作</th>
				</tr>
			</thead>
			<tbody>
				{volist name="newsClass" id="vo"}
				<tr>
					<!--<td>
						<div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='2'><i class="layui-icon">&#xe605;</i></div>
					</td>-->
					<td class="text-center">{$vo.id}</td>
					<td class="text-center">{$vo.name}</td>
					<td class="text-center">{$vo.sort}</td>
					<td class="td-manage text-center">
						<a title="编辑" onclick="x_admin_show('编辑','/modify_class/{$vo.id}.html','600px' ,'300px')" href="javascript:;">
							编辑
						</a>
						<a title="删除" onclick="deleteClass(this,{$vo.id})" href="javascript:;" style="margin-left:25px;">
							删除
						</a>
					</td>
				</tr>
				{/volist}
			</tbody>
		</table>
	</div>
	{include file="public/base_js"/}
	<script>
		/*监听更新操作*/
		window.addEventListener('storage', function (e) {
			console.log(e);
			if (e.key =='update_news_class') {
				window.location.reload(true);
			}
		}, false);
		//删除指定的分类id
		function deleteClass(obj, id) {
			layer.confirm('确认要删除吗？', function(index) {
				$.ajax({
					type:"post",
					url:"{:url('admin/newsClass/delete_class')}",
					data: {
						id: Number(id)
					},
					success: function (data) {
						if (data.success) {
							//发异步删除数据
							
							layer.msg('已删除!', {
								icon: 1,
								time: 1000
							},function () {
                 				window.localStorage.setItem('is_del_news_class',new Date().getTime()); 
								window.location.reload(true);
							});
						}
					},
					errorr: function () {
						layer.msg('删除失败!', {
							icon: 2,
							time: 1000
						});
					}
				});
				
			});
		}
	</script>

</body>

</html>